package com.cmpan.networkdisk.service;

import com.cmpan.networkdisk.dao.CommentMapper;
import com.cmpan.networkdisk.model.Comment;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * ClassName:CommentServiceImp
 * Package:com.cmpan.networkdisk.service
 * Description:
 *
 * @Date:2020/7/20 17:10
 * @com.chuangmei
 */
@Service
public class CommentServiceImp implements CommentService{

    @Resource
    private CommentMapper commentDao;

    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public int addComment(Comment comment) {
        int count = commentDao.insertSelective(comment);
        return count;
    }

    @Override
    public List<Comment> queryAll() {
        return commentDao.selectAll();
    }
}
